package com.example.hospitalapp;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class DoctorHomeActivity extends AppCompatActivity {

    private TextView txtDoctorName, txtDoctorDetails;
    private Button btnAppointments, btnMedicalRecords;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_doctor_home);

        txtDoctorName = findViewById(R.id.doctor_name);
        txtDoctorDetails = findViewById(R.id.tvDoctorDetails);
        btnAppointments = findViewById(R.id.btnAppointments);

        // 获取传递过来的医生信息
        Doctor doctor = (Doctor) getIntent().getSerializableExtra("doctor_info");
        if (doctor != null) {
            // 显示医生信息
            txtDoctorName.setText("姓名：" + doctor.getName());
            txtDoctorDetails.setText("专长：" + doctor.getSpecialty() + "\n手机号：" + doctor.getPhoneNumber());
        }

        // 按钮点击事件
        btnAppointments.setOnClickListener(view -> {
                int doctorId = doctor.getDoctorId();
                // 如果 doctorId 有效，跳转到预约记录页面
                Intent intent = new Intent(DoctorHomeActivity.this, DoctorAppointmentListActivity.class);
                intent.putExtra("doctorId", doctorId);  // 传递 doctorId 到预约记录页面
                startActivity(intent);  // 跳转到 DoctorAppointmentListActivity

        });

    }
}
